<?php

namespace app\admin\model;

use think\Model;

class User extends Common
{
	/**
	 * 获取登录用户信息
	 * @param $account
	 * @param $password
	 * @return null|static
	 */
	public function getAdminByLogin($account, $password) {
		return $this->get([
			'account' => $account,
			'password' => $password,
			'status' => 1,
			'delete' => 0
		]);
	}

	/**
	 * 检查用户名是否存在
	 * @param $where
	 * @return null|static
	 */
	public function getAdminByUsername($where) {
		return $this->get($where);
	}

	/**
	 * 获取管理员列表
	 * @param $where @查询条件
	 * @param $page @分页数据
	 * @return \think\Paginator
	 */
	public function getAdminList($where = [], $page = 15) {
		$data = $this->where($where)->where('delete', 0)->paginate($page);
		foreach ($data as $k => $v) {
			$role = model('JurisdictionGroup')->get(['id' => $v->AdminJurisdiction->jurisdiction_group_id]);
			$data[$k]['role_name'] = $role->data['name'];
		}
		return $data;
	}


}
